package cn.itcast.hotel.controller;

import cn.itcast.hotel.common.PageResult;
import cn.itcast.hotel.dto.HotelPageQueryDTO;
import cn.itcast.hotel.service.HotelService;
import cn.itcast.hotel.vo.HotelVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 酒店控制器
 *
 * @author liudo
 * @version 1.0
 * @project hotel-demo
 * @date 2023/8/27 15:39:21
 */
@RestController
@RequestMapping("/hotel")
@RequiredArgsConstructor
public class HotelController {

    private final HotelService hotelService;

    /**
     * 列表
     *
     * @param hotelPageQueryDTO 酒店页面查询d去
     * @return {@link PageResult}<{@link HotelVO}>
     */
    @PostMapping("/list")
    public PageResult<HotelVO> list(@RequestBody HotelPageQueryDTO hotelPageQueryDTO) {
        return hotelService.listByQuery(hotelPageQueryDTO);
    }

    /**
     * 过滤器
     *
     * @param hotelPageQueryDTO 酒店页面查询d去
     * @return {@link Map}<{@link String}, {@link List}<{@link String}>>
     */
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody HotelPageQueryDTO hotelPageQueryDTO) {
        return hotelService.filters(hotelPageQueryDTO);
    }

    /**
     * 建议
     *
     * @param key 钥匙
     * @return {@link List}<{@link String}>
     */
    @GetMapping("/suggestion")
    public List<String> suggestion(String key) {
        return hotelService.suggestion(key);
    }
}
